package tech.aistar.mapper.comment;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tech.aistar.entity.Answer;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2019/10/4 0004.
 */
@Repository
public interface AnswerMapper {
    //添加
    @Insert("insert into answer( id,userinfo_id,service_id,name,time,level,content,status) values(#{id},#{userinfoId},#{serviceId},#{name},#{time},#{level},#{content},#{status})")
    void anSave(Answer answer);

    @Select("select * from answer where id=#{value}")
    Answer anfindone(Integer id);

    @Select("select a.id,a.content,a.userinfo_id,a.status,u.name from answer a join user_info u on u.id = a.userinfo_id  where a.time=#{value} order by a.time ")
    List<Answer> antime(Date time);

    @Select("select * from answer where userinfo_id=#{value}")
    List<Answer> userId(Integer userinfoId);

    @Select("select * from answer where service_id=#{value} order by time")
    List<Answer> serviceId(Integer serviceId);

    @Update("update answer set counts = counts + 1 where id = #{value}")
    void ancounts(Integer id);

}
